<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        {{ name }}
        <input type="text" v-model="name">
        <button @click="fn">销毁 vue</button>
    </div>
</body>
<script src="./vue.js"></script>
<script>
    var vm = new Vue({
        methods: {
            fn() {
                this.$destroy()
            }
        },
        data: {
            name: 'xjj'
        },
        beforeCreate() {
            console.log('---------------beforeCreate------------------')
            console.log(this.name) // undefined
        },
        created() {
            console.log('----------------created-----------------')
            console.log(this.name) // 'xjj'
        },
        beforeMount() {
            console.log('-----------------beforeMount----------------')
            console.log(this.$el)
        },
        mounted() {
            console.log('-----------------mounted----------------')
            console.log(this.$el)
        },
        beforeUpdate() {
            console.log('-----------------beforeUpdate----------------')
            console.log(this.$el)
        },
        updated() {
            console.log('-----------------updated----------------')
            console.log(this.$el)
        },
        beforeDestroy() {
            console.log('-----------------beforeDestroy----------------')
        },
        destroyed() {
            console.log('-----------------destroyed----------------')
        }
    }).$mount('#app')
</script>

</html>